﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PowerWaveAddin.Uploaders
{
	abstract class AbstractUploader
	{
		#region Delegates/Events

		/// <summary>
		/// Handler for upload progress events.
		/// </summary>
		/// <param name="args"></param>
		public delegate void ProgressEventHandler(UploadProgressArgs args);
		private event ProgressEventHandler m_UploadProgress;

		#endregion

		#region Properties

		/// <summary>
		/// The GUI Contril representing this uploader's configuration.
		/// </summary>
		public abstract UploadConfigControl GuiControl { get; }

		/// <summary>
		/// The friendly display name of the uploader
		/// </summary>
		public abstract string FriendlyName { get; }

		/// <summary>
		/// Triggered after each slide finishes upload.
		/// </summary>
		public event ProgressEventHandler UploadProgress
		{
			add { m_UploadProgress += value; }
			remove { m_UploadProgress -= value; }
		}

		#endregion

		/// <summary>
		/// Begin the presentation upload
		/// </summary>
		/// <param name="presentationName"></param>
		/// <param name="filePaths"></param>
		public abstract void Upload(string presentationName, IEnumerable<string> filePaths);

		/// <summary>
		/// Gets the filenames and URIs of a presentation that has been completely uploaded.
		/// </summary>
		public abstract Dictionary<string, Uri> GetFileUriMapping();

		/// <summary>
		/// Raises the UploadProgress event
		/// </summary>
		/// <param name="args"></param>
		protected void RaiseUploadProgress(UploadProgressArgs args)
		{
			if (m_UploadProgress != null)
				m_UploadProgress(args);
		}
	}

	/// <summary>
	/// Arguments to the ProgressEventHandler
	/// </summary>
	internal class UploadProgressArgs
	{
		/// <summary>
		/// Total numer of slides being uploaded.
		/// </summary>
		public int TotalSlides { get; set; }

		/// <summary>
		/// The index of the last slide uploaded.
		/// </summary>
		public int LastSlideUploadedIndex { get; set; }

		/// <summary>
		/// The local path of the last slide uploaded.
		/// </summary>
		public string LastSlideUploadedPath { get; set; }

		/// <summary>
		/// The remote URI of the last slide uploaded.
		/// </summary>
		public Uri LastSlideUploadedUri { get; set; }
	}
}
